﻿using System.Collections.Generic;
using System.Collections;

namespace Library
{
    public class ComponentEnumerator : IEnumerator
    {
        int position = -1;
        CompCollection collection;
        List<int> ordered = new List<int>();

        public object Current 
        {
            get { return collection[ordered[position]]; }
        }

        public ComponentEnumerator(CompCollection Collection, List<int> order)
        {
            this.collection = Collection;
            this.ordered = order;
        }

        public bool MoveNext() 
        {
            position++;
            if (position == ordered.Count)
                return false;

            return true;
        }

        public IEnumerator GetEnumerator()
        {
            return this;
        }

        public void Reset()
        {
            position = -1;
        }
    }
}
